<form action="index.php/outside_contract/update/" method="post" enctype="multipart/form-data" name="myform" id="myform">
<div id="inline1">
<h2><span>外签合同信息</span></h2>
<table>
        <tr><th colspan="5">基本信息：</th></tr>
        <tr>
        	<td class="name" width="80"><span>*</span>主题：</td>
            <td colspan="4"><input class="text_width" style=" width:427px;" name="subject" id="subject" type="text" value=<?= $update_contract->subject ?> ></input></td>
        </tr>

        <tr>
        	<td class="name" width="80"><span>*</span>供应商：</td>
            <td colspan="4">
            	<input type="text" style=" width:427px;" autocomplete="off" id="suppliers_name" name="suppliers_name"  value=<?= $update_contract->suppliers_name ?>></input>
            </td>
        </tr>
        <tr>
            <td class="name" width="80">合同号：</td>
            <td width="170"><input type="text"  name="contract_no" value=<?= $update_contract->contract_no ?> ></input></td>
            <td>&nbsp;</td>
            <td class="name" width="80" style="padding-left:0px;">总金额：</td>
            <?php 
            if($update_contract->total_amount){
            	$total_amount = $update_contract->total_amount;
            }?>
            <td width="170"><input class="input_bg" name="total_amount" type="text" value=<?= $total_amount ?> ></input></td>
        </tr>
        <tr>
        	<td class="name" width="80">付款方式：</td>
            <td width="170">
            	<select name="payment_type">
                	<option value="支票" <?php if($update_contract->payment_type == '支票'):?>selected="selected"<?php endif;?>>支票</option>
                    <option value="现金" <?php if($update_contract->payment_type == '现金'):?>selected="selected"<?php endif;?>>现金</option>
                    <option value="银行转帐" <?php if($update_contract->payment_type == '银行转帐'):?>selected="selected"<?php endif;?>>银行转帐</option>
                    <option value="其它" <?php if($update_contract->payment_type == '其它'):?>selected="selected"<?php endif;?>>其它</option>
                </select>
            </td>
            <td>&nbsp;</td>
            <td class="name" width="80">交付地点：</td>
            <td width="170"><input name="payment_address" type="text" value=<?= $update_contract->payment_address ?> ></input></td>
        </tr>
        <tr>
        	<td class="name" width="80">开始时间：</td>
            <td width="170"><input type="text"  style="background:url(images/calendar.gif) right 1px no-repeat;" name="start_time" class="datepicker" value=<?php if($update_contract->start_time != '0000-00-00 00:00:00'):?> <?= $update_contract->start_time ?> <?php endif;?>></input></td>
            <td>&nbsp;</td>
            <td class="name" width="80">结束时间：</td>
            <td width="170"><input type="text"  style="background:url(images/calendar.gif) right 1px no-repeat;" class="datepicker" name="end_time" value=<?php if($update_contract->end_time != '0000-00-00 00:00:00'):?> <?= $update_contract->end_time ?> <?php endif;?> ></input></td>
        </tr>
        <tr>
            <td class="name" width="80">产品：</td>
            <td colspan="4"><input type="text" style=" width:427px;"  name="product" value=<?= $update_contract->product ?> ></input></td>
        </tr>
        <tr>
        	<td class="name" width="80">客户签约人：</td>
            <td width="170"><input type="text" name="customer_contract" value=<?= $update_contract->customer_contract ?> ></input></td>
            <td>&nbsp;</td>
            <td class="name" width="80">我方签约人：</td>
            <td width="170"><input type="text" name="our_contract"  value=<?= $update_contract->our_contract ?> ></input></td>
        </tr>
        <tr>
        	<td class="name" width="80">所有者：</td>
            <td width="170"><input type="text" name="user_name" value=<?= $update_contract->user_name ?> ></input></td>
            <td>&nbsp;</td>
            <td class="name" width="80">签约时间：</td>
            <td width="170"><input type="text"  style="background:url(images/calendar.gif) right 2px no-repeat;" class="datepicker" name="signing_time"  value=<?php if($update_contract->signing_time != '0000-00-00 00:00:00'):?> <?= $update_contract->signing_time ?> <?php endif;?>></input></td>
        </tr>
        <tr><th colspan="5">执行状态：</th></tr>
        <tr>
            <td class="name" width="80">状态：</td>
            <td width="170" colspan="4">
            	<select name="status">
                    <option <?php if($update_contract->status == '执行中'):?>selected="selected"<?php endif;?>>执行中</option>
                    <option <?php if($update_contract->status == '意外中止'):?>selected="selected"<?php endif;?>>意外中止</option>
                    <option <?php if($update_contract->status == '完成'):?>selected="selected"<?php endif;?>>完成</option>
                </select>
            </td>
        </tr>
        <tr><th colspan="5">其他：</th></tr>
        <tr>
            <td class="gj_name" width="80">合同正文及附件：</td>
            <td colspan="4">
            	<div class="tract_con">
                    <input type="text" class="tract_text" name="textfield" id="textfield" value="" />
                    <input type='button' class="tract_but" value='浏览' />
                    <input type="file" class="tract_file" name="userfile" onchange="document.getElementById('textfield').value=this.value" />
                </div>
            </td>
        </tr>
		<tr>
            <td class="gj_name" width="80">备注：</td>
            <td colspan="4"><textarea name="remark"><?= $update_contract->remark ?></textarea></td>
        </tr>
        <tr><td colspan="5">&nbsp;</td></tr>
        <tr class="sub">
            <td colspan="5"><input type="button" id="edit_outside_tijiao" value="提交" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="reset" value="重置" /></td>
        </tr>
    </table>
</div>
<input type="hidden" name="contract_id" value=<?= $update_contract->contract_id?> >
<input type="hidden" name="hiusname" value=<?= $update_contract->user_name?> >
<input type="hidden" name="hitext" value=<?= $update_contract->text_attachments?> >
<input type="hidden" name="hireal" value=<?= $update_contract->real_file_name?> >
<input type="hidden" id="type" value="1" ></input>
</form>
<input type="hidden" name="hicontract_no" value=<?= $update_contract->contract_no?> >
<script type="text/javascript">
$(function() {
		$( ".datepicker" ).datepicker();

		$("#edit_outside_tijiao").click(function(){
			var subject_val = $("#subject").val();
			var suppliers_name_val = $("#suppliers_name").val();
			var total_amount_val = $(":input[name='total_amount']").val();
			var error = '';
			if(!subject_val){
				error="错误：\x0d";
		        error+="主题不允许为空,请填写\x0d";
		        $("#subject").focus();
			}
			if(!suppliers_name_val){
				if(error==""){
			    	 error="错误：\x0d";
				 }
				 error+="供应商不允许为空,请填写\x0d";
				 if(!subject){
					  $("#subject").focus();
				  }else{
					  $("#suppliers_name").focus();
				}
			}
			if(total_amount_val){
				var re = /^[0-9]+.?[0-9]*$/;
				if (!re.test(total_amount_val)){
					if(error==""){
				    	 error="错误：\x0d";
					 }
					error+="总金额,输入需要是数字\x0d";
					$(":input[name='total_amount']").val('');
					$(":input[name='total_amount']").focus();
				}
			}
			
			if(error != ""){
		    	alert(error);
		    }else{
		    	var number_val=$(":input[name='contract_no']").val();
		    	var hinumber_val=$(":input[name='hicontract_no']").val();
		    	
		    	if(number_val != hinumber_val){
		    		$.post("index.php/outside_contract/check_outside_contract_number", { number: number_val },
							   function(data){
					    		if(data != ''){
								    alert('合同编号以添加');
								    $(":input[name='contract_no']").focus();
								    $(":input[name='contract_no']").val('');
								}else{
									$("#myform").submit();
								}
					});
				   }else{
					   $("#myform").submit();
					}
		    }
		})
});
</script>
